Repository navigation
Conversation
Rebuilds #217's 26 commits (previously 50c1b6d) on 5.x: the CraftCms\Cloud namespace, the slimmed CloudServiceProvider, Pint and PHPStan, and Pest on Testbench. Temporary pins: craftcms/cms at craftcms/cms#21032 and craftcms/http-cache at dev-main. Amp-Thread-ID: https://ampcode.com/threads/T-67f4021b-dc1c-4486-bc57-f39fdb7dabcf
timkelty
force-pushed
the
http-cache-port
branch
from
December 6, 2026 03:00
50c1b6d to
b467c23
Compare
Packagist already lists dev-timkelty/http-cache, so Composer no longer walks every cms tag and branch through the GitHub API. Amp-Thread-ID: https://ampcode.com/threads/T-67f4021b-dc1c-4486-bc57-f39fdb7dabcf
Craft split CacheInfo into CacheTags, for adding tags, and ResponseCacheInfo, for reading the response's tags and expiry date. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a1fc17-c592-763a-a600-e76afae5cd1f
Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a1fc17-c592-763a-a600-e76afae5cd1f
Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a1fc17-c592-763a-a600-e76afae5cd1f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds static page caching on Craft Cloud for Craft 6. It builds on Craft's
CacheInfo(craftcms/cms#21032) and the craftcms/http-cache package.Craft collects cache tags and element expiry. The package provides the cache profile, the tag header middleware and the invalidation flow. Cloud adds three things:
CacheResponseCDN-Cache-Control. It uses the page's own lifetime, or Cloud's default ofmax-age=1y, stale-while-revalidate=1h, capped atCacheInfo::getExpiryDate().CacheTagHeaderFormatterandCacheTagEncoderCache-Tagas{shortEnvironmentId}{crc32}hashes, within Cloudflare's 1,000-tag and 16 KiB limits. They add{environmentId}:overflowwhen tags are dropped. Purges use the same encoder.Gatewaycloudhttp-cache client, and the default one. It sends signed tag, URL, prefix and full purges to the gateway API. With'clients' => ['cloud' => ['soft_purge' => true]], tag purges go tocache/invalidate.On Cloud,
CloudServiceProviderregistersStaticCacheServiceProvider. Off Cloud, nothing changes.Behavior
CacheProfile::isResponseCacheable()rejects get noCDN-Cache-Control, even one the page set. That coversno-store,no-cache,privateand responses that set cookies. Cloudflare then follows theirCache-Control.RestrictCacheControlsends no-cache headers for sessions and token requests, so Cloud doesn't check them itself.Authorizationrequests don't get the default lifetime. An action that sets its own lifetime keeps it.cloud:static-cache:purge-{all,origin,cdn,tags,prefixes}purge directly.Important
Revert the composer pins once craftcms/cms#21032 merges and craftcms/http-cache is on Packagist.
craftcms/cmsis atdev-timkelty/http-cache, andcraftcms/http-cacheis atdev-mainthrough a VCS repository.craftcms/cms-assetsis aliased (6.x-dev as dev-timkelty/http-cache) inrequire-dev, because the core branch requires it atself.version.Follow-ups
These were in the closed #214:
element-(index|search)-query::*tags when purging.Related issues